#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:pengfeifu
@file: hannua.py 
@version:
@time: 2021/11/12 
@email:1324734112@qq.com
@desc： 递归算法
a,b,c 三跟支柱
将三个盘子从a挪到c
思路：
盘子从a到c
a-b
c-b
a-c
b-a
b-c
a-c
@function：常用函数
"""

# 移动次数
count = 0


def move(panzi, A, C):
    global count
    count += 1
    print(f"第{count}次移动。。。第{panzi}个盘子正在从{A}挪到{C}")


def hanno(num, A, B, C):
    if num == 1:
        move(1, A, C)
    else:
        hanno(num - 1, A, C, B)  # 从A挪到B,C变成中间支撑
        move(num, A, C)  # 从A挪到C
        hanno(num - 1, B, A, C)  # 从B挪到A，A变成中间支撑


if __name__ == "__main__":
    hanno(20, 'A', 'B', 'C')

    # 挪动次数，2^num-1
